package com.leyou.user.inter.api;

import com.leyou.common.bean.Result;
import com.leyou.common.bean.ServerConstant;
import com.leyou.user.inter.dto.UserLoginDTO;
import com.leyou.user.inter.dto.UserRegisterDTO;
import com.leyou.user.inter.fallback.UserServiceFallbackFactory;
import com.leyou.user.inter.pojo.User;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author zqq
 * @ClassName IUserService
 * @Description
 * @date 2020/3/9-20:17
 */
@Component
@FeignClient(value = ServerConstant.USER_SERVICE_ID, fallbackFactory = UserServiceFallbackFactory.class)
public interface IUserService {

    @RequestMapping(value = "/check/{data}/{type}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<Boolean> checkUserData(@PathVariable("data") String data,@PathVariable(value = "type") Integer type);

    @RequestMapping(value = "/code/{phone}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<Boolean> sendVerifyCode(@PathVariable(value = "phone") String phone);

    @RequestMapping(value = "/register", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<Boolean> register(@Valid @RequestBody UserRegisterDTO dto);

    @RequestMapping(value = "/login", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    Result<User> queryUser(@RequestBody UserLoginDTO dto);

}
